﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OpenQuarters.WebQuarters.Utils;

namespace OpenQuarters.WebQuarters.Core
{
    public class CMSEnvironment
    {
        public static bool NoScript
        {
            get
            {
                return (Oracle.Request.Form["cmsEnv_NoScript"] != null && Oracle.Request.Form["cmsEnv_NoScript"] == "true");
            }
        }

        public static bool EditMode
        {
            get
            {
                return ContextItem.GetItem<bool>("CMSEnvironment.EditMode", () => Core.User.Current.IsAuthenticated && Core.User.Current.HasPermission(Permissions.CMSPage.Edit.SetValue(CMSPage.Current.PageId.ToString())));
            }
        }

        public static LoggingMode? LoggingMode
        {
            get
            {
                return ContextItem.GetItem<LoggingMode?>("CMSEnvironment.LoggingMode", () => null);
            }
            set
            {
                ContextItem.SetItem<LoggingMode?>("CMSEnvironment.LoggingMode", value);
            }
        }
    }
}
